package com.ghf.dp2.Strategy;
//CashContext定义Strategy中的所有对象引用
// CashSuper为抽象策略，CashNormal、CashRebate为具体策略
public class CashContext {
    private CashSuper cashSuper = null;

    //与简单工厂结合,创建具体的策略对象
    public CashContext (String opt){
        switch (opt){
            case "正常":
                cashSuper =  new CashNormal();
                break;
            case "打折":
                cashSuper = new CashRebate();
                break;
            default:
                cashSuper = new CashNormal();
        }
    }

    public double getRes(double money){
        return cashSuper.acceptCash(money);
    }
}
